﻿using log4net;
using LuShanTea.Service.Entities;
using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Reflection;
using System.Runtime.Remoting.Contexts;
using System.Text;
using System.Threading.Tasks;

namespace LuShanTea.Service
{
    public class LuShanTeaContext : DbContext
    {
        ILog logger = LogManager.GetLogger(typeof(LuShanTeaContext));
        public LuShanTeaContext()
            : base("name=connStr")
        {
            //取消自动生成的表
            Database.SetInitializer<LuShanTeaContext>(null);
            this.Database.Log = sql =>
            {
                logger.Debug("Ef执行Sql：" + sql);
            };



        }
        public DbSet<Address> Address { get; set; }
        public DbSet<AdminUser> AdminUsers { get; set; }
        public DbSet<Area> Areas { get; set; }
        public DbSet<Cart> Carts { get; set; }
        public DbSet<CartRecord> CartRecords { get; set; }
        public DbSet<Category> Categories { get; set; }
        public DbSet<City> Cities { get; set; }
        public DbSet<Collect> Collects { get; set; }
        public DbSet<Comment> Comments { get; set; }
        public DbSet<Good> Goods { get; set; }
        public DbSet<GoodAttr> GoodAttrs { get; set; }
        public DbSet<GoodImgSrc> GoodImgSrcs { get; set; }
        public DbSet<IdName> IdNames { get; set; }
        public DbSet<Log> Logs { get; set; }
        public DbSet<Order> Orders { get; set; }
        public DbSet<OrderRecord> OrderRecords { get; set; }
        public DbSet<Pack> Packs { get; set; }
        public DbSet<Permission> Permissions { get; set; }
        public DbSet<Province> Provinces { get; set; }
        public DbSet<Role> Roles { get; set; }
        public DbSet<Setting> Settings { get; set; }
        public DbSet<User> Users { get; set; }

       
        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            base.OnModelCreating(modelBuilder);
            modelBuilder.Configurations.AddFromAssembly(Assembly.GetExecutingAssembly());
        }


    }
}
